package com.magic.gre.adapter;

import android.content.Context;
import android.view.View;

import com.magic.gre.R;
import com.noname.lib_base_java.adapter.CommonAdapter;
import com.noname.lib_base_java.adapter.ViewHolder;

import java.util.List;

/**
 * Author: Lmoumou
 * Date: 2019-01-14 18:21
 * 文件名: SearchHistoryAdapter
 * 描述:
 */
public class SearchHistoryAdapter extends CommonAdapter<String> {

    private OnHistoryItemClickLiatener onHistoryItemClickLiatener;

    public void setOnHistoryItemClickLiatener(OnHistoryItemClickLiatener onHistoryItemClickLiatener) {
        this.onHistoryItemClickLiatener = onHistoryItemClickLiatener;
    }

    public SearchHistoryAdapter(Context mContext, List<String> mData) {
        super(mContext, mData, R.layout.item_search_history);
    }

    @Override
    protected void bindData(ViewHolder holder, int position) {
        final String content = mData.get(position);
        holder.setText(R.id.content_tv,content);
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onHistoryItemClickLiatener!=null){
                    onHistoryItemClickLiatener.onHistoryItemClick(content);
                }
            }
        });

    }

    public interface OnHistoryItemClickLiatener{
        void onHistoryItemClick(String content);
    }
}
